package eerbaar.internal.area;

import java.util.ArrayList;
import java.util.List;

import eerbaar.area.ISquare;
import eerbaar.elements.IElementContainer;
import eerbaar.position.IPosition;
import eerbaar.position.PositionFactory;

public class Row {

    private final List<ISquare> squares = new ArrayList<ISquare>();

    public Row(IElementContainer container, int width, int rowNum) {
        for (int i = 0; i < width; i++) {

            IPosition pos = PositionFactory.createPosition(i, rowNum);

            this.squares.add(new Square(container, pos));
        }
    }

    public int getSize() {
        return this.squares.size();
    }

    public ISquare getSquare(int position) {
        return this.squares.get(position);
    }

    @Override
    public String toString() {
        StringBuilder s = new StringBuilder();
        s.append("[ ");
        for (ISquare square : this.squares) {
            s.append(" {" + square.toString() + "} ");
        }
        s.append(" ]");
        return s.toString();
    }

}
